const file_base = async(file)=>{
    return new Promise(async(resolve) => {
        let reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = async()=>{
            resolve(reader.result) 
        };
    })
}
const dataURItoBlob = (base64Data)=> {
    let filename = Date.parse(new Date())+ '.png'
    let arr = base64Data.split(',');
    let mime = arr[0].match(/:(.*?);/)[1];
    let bstr = atob(arr[1]);
    let n = bstr.length; 
    let u8arr = new Uint8Array(n);
    while(n--){
        u8arr[n] = bstr.charCodeAt(n);
    }
    //转换成file对象
    return new File([u8arr], filename, {type:mime});
  }
export {file_base,dataURItoBlob}